//
//  WDNetworkConfig.m
//  Pods
//
//  Created by Alean on 2022/12/1.
//

#import "WDNetworkConfig.h"

@implementation WDNetworkConfig

+ (instancetype)sharedConfig {
    static dispatch_once_t pred = 0;
    __strong static id _sharedObject = nil;
    dispatch_once(&pred, ^{
        _sharedObject = [self new];
    });
    return _sharedObject;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        self.timeoutSeconds = 20;
    }
    return self;
}

- (void)setHeaderValue:(NSString *)value key:(NSString *)key {
    if (!_customDict) {
        _customDict = @{key: value};
    } else {
        NSMutableDictionary *dict = _customDict.mutableCopy;
        [dict setValue:value forKey:key];
        _customDict = dict.copy;
    }
}

- (void)removeCustomHeadWithKey:(NSString *)key {
    NSMutableDictionary *dict = _customDict.mutableCopy;
    [dict removeObjectForKey:key];
    _customDict = dict.copy;
}

@end
